1
Foundations of C++ Arithmetic Types
AI037 Lesson 3
00:00

C++ defines a set of primitive arithmetic types that map directly to hardware storage. Imagine memory as a sequence of numbered addresses. Each byte (8 bits) is the smallest addressable unit, while a word (usually 32/64 bits) is the natural processing size.

1. Integral Types

Includes booleans (bool), characters (including Unicode char16_t, char32_t), and integers. Integers can be signed (representing negative, zero, and positive) or unsigned (values ≥ 0).

Table 2.1: C++ Arithmetic Types (Minimum Sizes) Type Meaning Min. Size bool Boolean (true/false) NA char Character 8 bits int Integer 16 bits double Double Precision Float 10 sig digits

2. Memory Representation

When an int occupies one word, it spans multiple byte addresses. For instance, an object starting at address 736424 occupies 4 bytes of contiguous memory.

32-bit Integer spanning 4 Bytes 00011011 10100101 01110010 00001111 736424 736425 736426 736427

3. Floating-Point & Void

Floating-point types (float, double, long double) represent real numbers via machine bit patterns. The void type signifies an "empty" result; it has no values and cannot be used to declare a standard variable.

main.py
TERMINAL bash — 80x24
> Ready. Click "Run" to execute.
>